package leedcode_path.treeNoDE;

public class 累加树 {
    /*
    题目为https://leetcode.cn/problems/convert-bst-to-greater-tree/description/
    * */
    int sum=0;
    public TreeNode convertBST(TreeNode root) {
        if (root==null) return null;
        bfs(root);
        return root;


    }
    public void bfs(TreeNode root){
        if (root==null) return;
        bfs(root.right);
        sum+=root.val;
        root.val=sum;
        bfs(root.left);
    }
}
